package com.cincc.cinccimdemo.ui.me.favorite.viewholder;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.cincc.cinccimdemo.R;
import com.cincc.im.model.CollectModel;
import com.cincc.im.util.Base64Util;

import org.json.JSONObject;

public class FavTextContentViewHolder extends FavContentViewHolder {
    TextView favTextContentTextView;

    public FavTextContentViewHolder(@NonNull View itemView) {
        super(itemView);
        bindViews(itemView);
    }

    private void bindViews(View itemView) {
        favTextContentTextView = itemView.findViewById(R.id.favTextContentTextView);
    }

    @Override
    public void bind(Activity context, CollectModel item) {
        super.bind(context, item);
        try {
            String data = Base64Util.decodeToString(item.messageContent);
            JSONObject jsonObject = new JSONObject(data);
            favTextContentTextView.setText(jsonObject.getString("msgContent"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onClick() {
        //WfcWebViewActivity.loadHtmlContent(fragment.getActivity(), "收藏内容", favoriteItem.getTitle());
    }
}
